<%@ page language="java" contentType="application/x-javascript; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/commons/pages/taglibs.jsp" %>

<c:forEach var="cur" items="${typeInfoList}" varStatus="vs"> function format${cur.type_sign}(value) {
  <c:set var="type_codes" value="${fn:split(cur.type_value, ',')}" />
  <c:set var="type_names" value="${fn:split(cur.type_name , ',')}" />
  switch (value) {
  <c:forEach var="cur1" begin="0" end="${fn:length(type_codes) - 1}" varStatus="vs1"> case ${type_codes[vs1.index]}:return '${type_names[vs1.index]}'; </c:forEach>
  }
  }
  <c:if test="${not empty(cur.type_style)}"> function style${cur.type_sign}(value) {
    <c:set var="type_codes" value="${fn:split(cur.type_value, ',')}" />
    <c:set var="type_styles" value="${fn:split(cur.type_style , ',')}" />
    switch (value) {
    <c:forEach var="cur1" begin="0" end="${fn:length(type_codes) - 1}" varStatus="vs1"> case ${type_codes[vs1.index]}:return '${type_styles[vs1.index]}'; </c:forEach>
    }
    } </c:if>
</c:forEach>
Date.prototype.format = function(style) {
	var o = {
		"M+" : this.getMonth() + 1, //month
		"d+" : this.getDate(),      //day
		"h+" : this.getHours(),     //hour
		"m+" : this.getMinutes(),   //minute
		"s+" : this.getSeconds(),   //second
		"w+" : "\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d".charAt(this.getDay()),   //week
		"q+" : Math.floor((this.getMonth() + 3) / 3),  //quarter
		"S"  : this.getMilliseconds() //millisecond
	};
	if (/(y+)/.test(style)) {
		style = style.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	}
	for(var k in o){
		if (new RegExp("("+ k +")").test(style)){
			style = style.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
		}
	}
	return style;
};

String.prototype.leftPad = function(n, s) {  
    s = s || " ";  
    if (this.length < n) {  
        var ts = new Array(n - 1);  
        ts[n - 1] = this;  
        for (var i = 0; i < n - this.length; i++) {  
            ts[i] = s;  
        }  
        return ts.join("");  
    } else {  
        return this;  
    }  
} 

function formatDate(value){
	return typeof(value) == 'number' ? new Date(value).format("yyyy-MM-dd") : '';
}

function formatDateTime(value){
	return typeof(value) == 'number' ? new Date(value).format("yyyy-MM-dd hh:mm:ss") : '';
}

function formatDateTimeNoYear(value){
	return typeof(value) == 'number' ? new Date(value).format("M/dd hh:mm:ss") : '';
}